﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DLM.Domain.Model;
using DLM.Domain.Repositories;

namespace DLM.Services.Implementations
{
    public class PartyBusinessRules
    {

        private IPartyRepository partyRepository;
        private IUserPartyAssociationRepository userPartyAssRepository;

        public PartyBusinessRules(IPartyRepository partyRepository, IUserPartyAssociationRepository userPartyRepository)
        {
            this.partyRepository = partyRepository;
            this.userPartyAssRepository = userPartyRepository;
        }


        public bool CanParticipateIn(UserPartyAssociation ups)
        {
            bool result = false;
            if (ups == null)
            {
                throw new ArgumentNullException("user id");
            }
            var list = userPartyAssRepository.FindAll(p => p.UserID == ups.UserID);
            foreach (var item in list)
            {
                if (item.AssociationDate.Date == ups.AssociationDate.Date)
                {
                    result = true;
                }
            }
            return result;

        }
        //public IDictionary<string, object> Validate()
        //{

        //}
    }
}
